function [m,x,s] = powermethod(n,a,eps)
%UNTITLED 此处显示有关此函数的摘要
%   此处显示详细说明
M = 5000000;
A = zeros(n);
for i = 1:n
    A(i,n) = -a(i);
end
for i = 2:n
    for j = 1:n-1
        if i-j == 1
            A(i,j) = 1;
        end
    end
end
s = 0;
n = max (size (A) ) ;
u = ones (n,1) ;
y = ones (n,1) ;
betal = 0 ;
eta = norm(u,2) ;
y = u./eta;
u = A*y;
beta2 = y' *u;
while s <= M
    if abs ( (beta2 -betal) /betal) > eps
        betal = beta2;
        eta = norm(u,2) ;
        y = u./eta;
        u = A * y;
        beta2 = y' * u; 
    end
    s=s+1 ;
    if (abs ( (beta2 - betal) /betal) <=eps)
    break;
    end
end
m = beta2;
x = y;
end

